package Java_Concurrency_in_Practice.c3_2;

import java.awt.Event;
import java.util.EventListener;

public class SafeListener {
	
	private final EventListener listener;
	
	private SafeListener() {
		listener = new EventListener() {
			public void onEvent(Event e) {
				doSomething(e);
			}
		};
	}
	
	public static SafeListener newInstance(EventSource source) {
		SafeListener safe = new SafeListener();
		source.registerListener(safe.listener);
		return safe;
	}
	
	private void doSomething(Event e) {
		
	}
	
	public static void main(String[] args) {
		SafeListener safe = SafeListener.newInstance(new EventSource());
		
		
		
	}
}
